<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>运维功能——一键生成</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/crypto/crypto-js.js"></script>
    <style type="text/css">
        body {
            margin:0;
            padding:0;
            border:0;
            width:100%;
            height:100%;
            overflow:hidden;
        }
    </style>
</head>
<body>
<div class="role-search">
    <div class="mini-toolbar" style="padding:2px;border-top:0;border-left:0;border-right:0;">
        <table>
            <tr>
                <td style="width: 100%;">
                    <a class="mini-button" iconCls="fa fa-plus" onclick="click()" plain="true">新增</a>
                </td>
                <td class="discell" style="white-space: nowrap;text-align:right;color:red">*该页面的删除功能仅对于通过测试账号进行的操作，对普通账号生成的数据无用，谨记！@！@！</td>
            </tr>
        </table>
    </div>
</div>
<!--撑满页面-->
<div class="mini-fit">
    <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 100%;" ajaxType="get" multiSelect="false"
         sizeList="[20,50,100]" pageSize="50" virtualScroll="false" showLoading="true"
         idField="id" url="/azbj/maintenance/selectAccountAll">
        <input name="orgid" class="mini-hidden" style="width: 100%;" readonly />
        <div property="columns">
            <div type="indexcolumn" width="10" headerAlign="center">序号</div>
            <div name="serialNumber" field="serialNumber" align="center" width="20" headerAlign="center" allowSort="false">序列号</div>
            <div name="serialNumber" field="serialNumber" align="center" width="20" headerAlign="center" allowSort="false" renderer="setDate">生成时间</div>
            <div name="action" headerAlign="center" align="center" width="10" renderer="onActionRenderer" cellStyle="padding:0;"
                 allowSort="false" multiSelect="false">操作
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    mini.parse();
    var grid = mini.get("datagrid1");
    grid.load();

    $(function (){

    });
    //渲染列中按钮
    function onActionRenderer(e) {
        var s = '';
        s += '&nbsp;<a class="mini-button mini-button-info"  onclick="selectAccount()" >&nbsp;查看&nbsp;</a>&nbsp';
        s += '&nbsp;<a class="mini-button mini-button-danger"   onclick="delAccount();" >&nbsp;删除&nbsp;</a>&nbsp';
        return s;
    }

    //新增账号操作
    function click(){
        mini.confirm("该页面的删除功能仅对于通过测试账号进行的操作，对普通账号生成的数据无用",
            "确定",
            function (action) {
                if (action == "ok") {
                    maskLayer();
                    $.ajax({
                        url: '/azbj/maintenance/generateAccount',
                        type: "GET",
                        success: function (res) {
                            mini.unmask();
                            if(res.code===1){
                                mini.alert("生成成功");
                                grid.load();
                            }else {
                                mini.alert("生成失败");
                            }
                        },
                        error: function () {
                            mini.unmask();
                            mini.alert("生成失败");
                        }
                    });
                }
            });
    }

    //删除数据
    function delAccount() {
        var row = grid.getSelected();
        if (row) {
            commonRemove("/azbj/maintenance/delAutoAccount/" + row.serialNumber, row, {_method: "delete"}, callback);
            function callback() {
                grid.reload();
            }
        } else {
            mini.alert("请至少选中一条记录");
        }
    }

    //查看数据
    function selectAccount(){
        var row = grid.getSelected();
        if(row){
            commonEdit("/azbj/dsrw/regularCleanSql/toGetAutoAccount/view?serialNumber=" + row.serialNumber, "账号信息", null, 600, 500, true, false, true, callback);
            function callback() {
                grid.reload();
            }
        } else {
            mini.alert("请至少选中一条记录");
        }
    }

    //处理时间
    function setDate(e){
        var data = e.value.substring(12,26);
        return data.substring(0,4)+'-'+data.substring(4,6)+'-'+data.substring(6,8)+' '+data.substring(8,10)+':'+data.substring(10,12)+':'+data.substring(12,14);
    }

    //遮罩层
    function maskLayer(){
        mini.mask({
            el: document.body,
            cls: 'mini-mask-loading',
            html: '数据加载中…'
        });
    }
</script>
</body>
</html>